// ==++==
//
//   
//    Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
//   
//    The use and distribution terms for this software are contained in the file
//    named license.txt, which can be found in the root of this distribution.
//    By using this software in any fashion, you are agreeing to be bound by the
//    terms of this license.
//   
//    You must not remove this notice, or any other, from this software.
//   
//
// ==--==
using System;
using System.IO;
using System.Collections;
using System.Globalization;
using System.Text;
using System.Threading;
public class Co7064GetTypeCode
{
 public static String s_strActiveBugNums = "";
 public static String s_strDtTmVer       = "";
 public static String s_strClassMethod   = "GetTypeCode (Object)"; 
 public static String s_strTFName        = "Co7064GetTypeCode.cs";
 public static String s_strTFAbbrev      = s_strTFName.Substring(0,6);
 public static String s_strTFPath        = "";
 public bool runTest()
   {
   Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
   String strLoc = "Loc_000oo";
   String strValue = String.Empty;
   int iCountErrors = 0;
   int iCountTestcases = 0;
   try
     {
     TypeCode tcTest;
     strLoc = "Loc_100vy";
     iCountTestcases++;
     tcTest = Convert.GetTypeCode (null); 	
     if (tcTest != TypeCode.Empty)
       {
       ++iCountErrors;	
       printerr( "Error_100aa! Sent In: null, Expected: TypeCode.Empty, Recieved: " + tcTest);
       }
     strLoc = "Loc_201vy";
     Object[] Test = 
     {
       DBNull.Value,
       new Boolean (),
       new Char (),  
       new SByte (),
       new Byte (),
       new Int16 (),
       new UInt16 (),
       new Int32(),
       new UInt32(),
       new Int64 (),
       new UInt64 (),
       new Single (),
       new Double (), 
       new Decimal (),
       new DateTime ()
     };
     for (Int32 i = 2; i <= Test.Length; i++)
       {
       iCountTestcases++;
       tcTest = Convert.GetTypeCode (Test [i - 2]); 	
       if ((int)tcTest != i)
	 {
	 ++iCountErrors;	
	 printerr( "Error_200aa" + i + "! Expected: " + i + " Recieved: " + tcTest);
	 }
       }			
     strLoc = "Loc_301vy";
     iCountTestcases++;
     Object oTest = new Object ();
     tcTest = Convert.GetTypeCode (oTest); 	
     if (tcTest != TypeCode.Object)
       {
       ++iCountErrors;	
       printerr( "Error_300aa! Sent In: Object, Expected: TypeCode.Object, Recieved: " + tcTest);
       }			
     } catch (Exception exc_general ) {
     ++iCountErrors;
     Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
     }
   if ( iCountErrors == 0 )
     {
     Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
     return true;
     }
   else
     {
     Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
     return false;
     }
   }
 public void printerr ( String err )
   {
   Console.WriteLine ("POINTTOBREAK: ("+ s_strTFAbbrev + ") "+ err);
   }
 public void printinfo ( String info )
   {
   Console.WriteLine ("INFO: ("+ s_strTFAbbrev + ") "+ info);
   }
 public static void Main(String[] args)
   {
   bool bResult = false;
   Co7064GetTypeCode cbA = new Co7064GetTypeCode();
   try {
   bResult = cbA.runTest();
   } catch (Exception exc_main){
   bResult = false;
   Console.WriteLine(s_strTFAbbrev + " : FAiL! Error Err_9999zzz! Uncaught Exception in main(), exc_main=="+exc_main.ToString());
   }
   if (!bResult)
     {
     Console.WriteLine ("Path: "+s_strTFPath+"\\"+s_strTFName);
     Console.WriteLine( " " );
     Console.WriteLine( "FAiL!  "+ s_strTFAbbrev);
     Console.WriteLine( " " );
     }
   if (bResult) Environment.ExitCode = 0; else Environment.ExitCode = 1;
   }
}
